package com.school.revervationSys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.school.revervationSys.entity.KnowledgeNotice;
import com.school.revervationSys.mapper.KnowledgeNoticeMapper;
import com.school.revervationSys.service.KnowledgeNoticeService;
import org.junit.platform.commons.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class KnowledgeNoticeServiceImpl extends ServiceImpl<KnowledgeNoticeMapper, KnowledgeNotice> implements KnowledgeNoticeService {



    @Autowired
    private KnowledgeNoticeMapper knowledgeNoticeMapper;

    public boolean addknowledgeNotice(KnowledgeNotice knowledgeNotice) {
        return this.save(knowledgeNotice);
    }

    public boolean updateknowledgeNotice(KnowledgeNotice user) {
        return this.updateById(user);
    }

    public boolean delete(Integer knowledgeNoticeId) {

        return this.removeById(knowledgeNoticeId);
    }
    public boolean batchDelete(List<Integer> ids) {

        return this.removeByIds(ids);
    }


    public KnowledgeNotice knowledgeNoticeInfo(String id){

        return this.getById(id);
    }

    public List<KnowledgeNotice> knowledgeNoticeList(String title){

        List<KnowledgeNotice> knowledgeNotices = knowledgeNoticeMapper.selectList(new QueryWrapper<KnowledgeNotice>()
                .lambda()
                .like(StringUtils.isNotBlank(title), KnowledgeNotice::getTitle, title));

        return knowledgeNotices;
    }


}
